<template>
  <div v-html="payHtml">{{payHtml}}</div>
</template>

<script>
import {skl_postInitiateOrder} from "../../../serve/api";
import Cookies from "js-cookie";
import {Toast} from "vant";

export default {
  name: "payHtml",
  data(){
    return{
      payHtml: '',
      addId:''
    }
  },
  mounted(){
    this.addId = this.$route.params.addr_id;
    // alert(this.addId);
    this.Pay();
  },
  methods:{
    async Pay(){
      //alert("456");
      let res = await skl_postInitiateOrder(接口参数);//skl_postInitiateOrder 接口方法
      if(res.error == 0) {
        let form = res.info;
        this.payHtml = form;
        this.$nextTick(() => {
          document.getElementById('alipaysubmit').submit()
          // document.forms["alipaysubmit"].submit();    //渲染支付宝支付页面
        })
      }
      else {
        //alert("2");
        Toast({
          message: "支付失败",
          duration: 1000
        });
      }
    },
  },
  destroyed: function () {//离开时销毁
    console.log("我已经离开了！");
    //this.stopTimer();
    this.$router.push('/order/payresult');
  }

}
</script>

<style scoped>

</style>
